package com.hx.demo28.controller;

import com.hx.demo28.pojo.Admin;
import com.hx.demo28.service.AdminService;
import com.hx.demo28.utils.Code;
import com.hx.demo28.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin")
@CrossOrigin
public class AdminController {
    @Autowired
    private AdminService adminService;

    @RequestMapping("/find")
    public Result findById(@RequestBody Admin admin){
        Admin byId = adminService.findById(admin);
        if (byId!=null){
            return new Result(Code.GET_OK,admin,"查询成功");
        }else {
            return  new Result(Code.GET_ERR,"查询失败");
        }
    }
}
